<?php

namespace app\common\model;

/**
 * [OrderRefund  订单退款表]
 * @author [C。]
 * @return html
 */
class OrderRefund extends Base
{
    protected $name = 'order_refund';
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getlist($map,$from = 0, $size = 5,$field='*')
    {
        $order = ['o.update_time' => 'desc'];
        $join1 = [
            ['app_goods g','g.id = o.goodsid'],
        ];
        $join2 = [
            ['app_goods_option go','go.id = o.optionid'],
        ];
        $join3 = [
            ['app_order o','o.id = r.orderid'],
        ];

        $result =  $this->field($field)
            ->alias('r')
            ->join($join3)
            ->join($join1)
            ->join($join2)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }

    /**
     * 搜索获取寺院列表总数
     * @param array $param
     */
    public function getCount($map) {
        $join1 = [
            ['app_goods g','g.id = o.goodsid'],
        ];
        $join2 = [
            ['app_goods_option go','go.id = o.optionid'],
        ];
        $join3 = [
            ['app_order o','o.id = r.orderid'],
        ];
        $result =  $this->alias('r')
            ->join($join3)
            ->join($join1)
            ->join($join2)
            ->where($map)
            ->count();

        return $result;
    }
}